package com.yycwxt.modules.admin.cbxs;

import com.yycwxt.common.ReturnResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/cbxs")
@Api("成本销售")
@Validated
public class CbxsController {
    private CbxsService se;

    @Autowired
    public CbxsController(CbxsService se){
        this.se = se;
    }

    @GetMapping("/index/{zq}")
    @ApiOperation("根据账期查询成本销售")
    public ReturnResult greet(@ApiParam(name = "zq", required = true, type = "int")@PathVariable int zq){
        return ReturnResult.buildSuccessResult(se.selectCbxx(zq));
    }

    @GetMapping()
    @ApiOperation("查询全部账期")
    public ReturnResult findad(){
        return ReturnResult.buildSuccessResult(se.findad().stream().distinct().toList());
    }

    @GetMapping("/getUrl")
    @ApiOperation("获取成本销售的URL")
    public ReturnResult getUrl(@ApiParam(name = "文件名" ,required = true, type = "string")  String name){
        return ReturnResult.buildSuccessResult(se.getUrl(name));
    }

}
